﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>我的桌面</title>
<style type="text/css">
.page-container>div {
	background: #F5FAFE;
	width: 25%;
	height: 100px;
	text-align: center;
	float: left;
	padding: 10px;
	line-height: 52px;
	margin-left: 15%;
	margin-top: 8%;
	position: relative;
}

.page-container>div>p {
	margin: 0;
	color: #B1B1B1;
}

.page-container>div>p:nth-child(1) {
	font-size: 35px;
	color: red;
}

.img1 {
	position: absolute;
	left: 73%;
	top: 14px;
	width: 20px;
	height: 30px;
	display: none;
}

.img2 {
	position: absolute;
	left: 73%;
	top: 37px;
	width: 20px;
	height: 30px;
	display: none;
}
</style>
</head>
<body>
	<div class="page-container" v-show="pageData.total">
		<div>
			<p id="sb"></p>
			<p>设备总数</p>
			<img src="/images/arrows_up.png" class="img1" />
			<img src="/images/arrows_down.png" class="img2" />
		</div>
		<div>
			<p id="sp"></p>
			<p>商品总数</p>
			<img src="/images/arrows_up.png" class="img1" />
			<img src="/images/arrows_down.png" class="img2" />
		</div>
		<div>
			<p id="tf"></p>
			<p>投放总数</p>
			<img src="/images/arrows_up.png" class="img1" />
			<img src="/images/arrows_down.png" class="img2" />
		</div>
		<div>
			<p id="jl"></p>
			<p>累积展示次数</p>
			<img src="/images/arrows_up.png" class="img1" />
			<img src="/images/arrows_down.png" class="img2" />
		</div>
	</div>
	<script type="text/javascript" src="/js/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="/js/lib/h-ui/js/H-ui.js"></script>
	<script src="/js/lib/countUp.js"></script>

</body>
</html>
<script type="text/javascript" src="/js/lib/layer/2.1/layer.js"></script>
<script>
function query() {
	var tip = layer.load(0, {shade: false});
	
	$.ajax({
	    type: "POST",
	    url: '/manager/device/getcount',
	    data:{pageNo: 1,
	    	pageSize: 10
	    },
	    beforeSend: function () {
	    },
	    complete: function () {
	    	layer.close(tip);
	    },
	    error: function(request) {
	        layer.alert("系统错误");
	    },
	    success: function(result) {
	        if (result.status == 0) {
	        	var data = result.data;
	        	//本地存储
	        	var local=data.total;	            
	            var storage=localStorage;
	            storage.setItem("value0",local);
	            var value0=localStorage.getItem("value0");
	            if(value0<data.total){
	            	$(".img1").eq(0).show();
	            }else if(value0>data.total){
	            	$(".img2").eq(0).show();
	            }
	            setTimeout(function(){
	            	$(".img1").eq(0).fadeOut();
	            	$(".img2").eq(0).fadeOut();
	            },2000)
	            var options = {
	                		  useEasing: true, 
	                		  useGrouping: true, 
	                		  separator: ',', 
	                		  decimal: '.', 
	                		};
	           var demo = new CountUp('sb', value0, data.total, 0, 2, options);
	                if (!demo.error) {
	                		demo.start();
	                } else {
	                	console.error(demo.error);
	                }	                		
	        } 
	    }
	});
	
	$.ajax({
	    type: "POST",
	    url: '/manager/product/getcount',
	    data:{pageNo: 1,
	    	pageSize: 10
	    },
	    beforeSend: function () {
	    },
	    complete: function () {
	    	layer.close(tip);
	    },
	    error: function(request) {
	        layer.alert("系统错误");
	    },
	    success: function(result) {
	        if (result.status == 0) {
	        	var data = result.data;
	        	//本地存储
	        	var local=data.total;	            
	            var storage=localStorage;
	            storage.setItem("value1",local);
	            var value1=localStorage.getItem("value1");
	            if(value1<data.total){
	            	$(".img1").eq(1).show();
	            }else if(value1>data.total){
	            	$(".img2").eq(1).show();
	            }
	            setTimeout(function(){
	            	$(".img1").eq(1).fadeOut();
	            	$(".img2").eq(1).fadeOut();
	            },2000)
	            var options = {
	                		  useEasing: true, 
	                		  useGrouping: true, 
	                		  separator: ',', 
	                		  decimal: '.', 
	                		};
	           var demo = new CountUp('sp', value1, data.total, 0, 2, options);
	                if (!demo.error) {
	                		demo.start();
	                } else {
	                	console.error(demo.error);
	                }

	        } 
	    }
	});
	
	$.ajax({
	    type: "POST",
	    url: '/manager/deviceproductrecord/getCount',
	    beforeSend: function () {
	    },
	    complete: function () {
	    	layer.close(tip);
	    },
	    error: function(request) {
	        layer.alert("系统错误");
	    },
	    success: function(result) {
	        if (result.status == 0) {
	        	var data = result.data;
	        	//本地存储
	        	var local=data.total;	            
	            var storage=localStorage;
	            storage.setItem("value2",local);
	            var value2=localStorage.getItem("value2");
	            if(value2<data.total){
	            	$(".img1").eq(2).show();
	            }else if(value2>data.total){
	            	$(".img2").eq(2).show();
	            }
	            setTimeout(function(){
	            	$(".img1").eq(2).fadeOut();
	            	$(".img2").eq(2).fadeOut();
	            },2000)
	            var options = {
	                		  useEasing: true, 
	                		  useGrouping: true, 
	                		  separator: ',', 
	                		  decimal: '.', 
	                		};
	           var demo = new CountUp('tf', value2, data.total, 0, 2, options);
	                if (!demo.error) {
	                		demo.start();
	                } else {
	                	console.error(demo.error);
	                }
	        } 
	    }
	});

	$.ajax({
	    type: "POST",
	    url: '/manager/reviewcount/queryPage',
	    data:{pageNo: 1,
	    	pageSize: 10
	    },
	    beforeSend: function () {
	    },
	    complete: function () {
	    	layer.close(tip);
	    },
	    error: function(request) {
	        layer.alert("系统错误");
	    },
	    success: function(result) {
	        if (result.status == 0) {
	        	var data = result.data;
	        	if(data.total>0){
	        		var total =0
	        		for(var i=0;i<data.rows.length;i++){
	        			total+=data.rows[i].count
	        		}
	        		//本地存储
		        	var local=total;	            
		            var storage=localStorage;
		            storage.setItem("value3",local);
		            var value3=localStorage.getItem("value3");
		            if(value3<total){
		            	$(".img1").eq(3).show();
		            }else if(value3>total){
		            	$(".img2").eq(3).show();
		            }
		            setTimeout(function(){
		            	$(".img1").eq(3).fadeOut();
		            	$(".img2").eq(3).fadeOut();
		            },2000)
		            var options = {
		                		  useEasing: true, 
		                		  useGrouping: true, 
		                		  separator: ',', 
		                		  decimal: '.', 
		                		};
		           var demo = new CountUp('jl', value3, total, 0, 2, options);
		                if (!demo.error) {
		                		demo.start();
		                } else {
		                	console.error(demo.error);
		                }
	        	}else{
	        		$("#jl").html(0);
	        	}
	        	

	        } 
	    }
	});
}
$(function() {
	query();
	
	$("#sb").click( function () {
		window.location='/manager/device/list';
		});
	$("#sp").click( function () {
		window.location='/manager/product/list';
		});
	$("#tf").click( function () {
		window.location='/manager/deviceproductrecord/list';
		});

	
});
</script>
